<?php

set_include_path(get_include_path() . PATH_SEPARATOR . '..');

require_once 'simpletest/autorun.php';
require_once 'database_engine/common_engine.php';
require_once 'database_engine/datareader_stub.php';
require_once 'components/grid_view.php';

class GridViewTests extends UnitTestCase
{
    public function testGrid()
    {
        $dataReader = new EditableDataReaderStub(
            array("id" => 1, "value" => "string value 1"),
            array("id" => 2, "value" => "string value 2")
        );

        $grid = new GridView('', new Renderer("../components/templates"), $dataReader);
        
        $column1 = $grid->AddFieldColumn("id");
        $columnViewProperties1 = new PlainTextViewProperties();
        $column1->SetViewProperties($columnViewProperties1);

        $column2 = $grid->AddFieldColumn("value");
        $columnViewProperties2 = new PlainTextViewProperties();
        $column2->SetViewProperties($columnViewProperties2);

        $this->assertEqual('<table class="pgui-grid-view"><thead></thead><tbody></tbody></table>',
            $grid->RenderGridContainer());
    }
}

?>